--透视效果
local kernel = {}

kernel.category = "filter"
kernel.name = "perspective"
 
-- Shader code uses time environment variable CoronaTotalTime
kernel.isTimeDependent = true
 
kernel.vertexData =
{
    {
        name = "xPosition",
        default = 0.5, 
        min = -1,
        max = 1,
        index = 0,  -- This corresponds to "CoronaVertexUserData.x"
    },
}
 
kernel.fragment = [[

    P_COLOR vec4 drawTex(P_UV vec2 uv)
    {	
    	P_UV vec2 new_uv = uv;
        new_uv.y= pow(uv.y, 0.7);
        //new_uv.x -= (step(0.5,uv.x) - 0.5)*2.0*abs(uv.x - 0.5)*0.5*new_uv.y;
        new_uv.x -= (step(CoronaVertexUserData.x,uv.x) - 0.5)*2.0*abs(uv.x - CoronaVertexUserData.x)*0.5*new_uv.y;
   
       
        P_COLOR vec4 texColor = texture2D( CoronaSampler0, new_uv);

        return texColor;
    }

        P_COLOR vec4 FragmentKernel( P_UV vec2 texCoord )
    {
        P_UV vec2 uv = texCoord.xy; //- vec2(0.5,0.5) ;
        return CoronaColorScale(drawTex(uv));
    }
]]

if not globalGroup.shaderRecoder[kernel.name] then
    graphics.defineEffect(kernel)
    globalGroup.shaderRecoder[kernel.name] = true
end

